﻿using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace MyTask
{
    public class MyTouch : Task
    {
        public override bool Execute()
        {
            DateTime now = DateTime.Now;
            Log.LogMessage(now.ToString() +
               " is now the new date for the following files:");
            try
            {
                foreach (string fileName in m_FilesNames)
                {
                    Log.LogMessage("   " + fileName);
                    System.IO.File.SetLastWriteTime(fileName, now);
                }
            }
            catch (Exception ex)
            {
                Log.LogErrorFromException(ex, true);
                return false;
            }
            return true;
        }
        [Required]
        public string[] Files
        {
            get { return (m_FilesNames); }
            set { m_FilesNames = value; }
        }
        private string[] m_FilesNames;
    }
}